/*

 * Licensed to the Apache Software Foundation (ASF) under one

 * or more contributor license agreements.  See the NOTICE file

 * distributed with this work for additional information

 * regarding copyright ownership.  The ASF licenses this file

 * to you under the Apache License, Version 2.0 (the

 * "License"); you may not use this file except in compliance

 * with the License.  You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */

package com.bff.gaia.unified.sdk.transforms.xjoin.client.rdb.parser;



import java.util.ArrayList;

import java.util.List;

import com.bff.gaia.unified.sdk.schemas.Schema;

import com.bff.gaia.unified.sdk.transforms.xjoin.client.rdb.table.RdbSideTableInfo;



/**

 * Project Name: gaia-parent Description: Data: 2019/7/20 10:53 Company: NEU

 *

 * @author tiger

 * @version v1.0

 */

public class RdbSideTableInfoBuilders {



  private static final String MYSQL_TYPE = "mysql";



  public static MysqlTableInfoBuilder buildMysqlTableInfo() {

    return new MysqlTableInfoBuilder();

  }



  public static class MysqlTableInfoBuilder {

    private final RdbSideTableInfo mysqlSideInfo;

    private final List<Schema.Field> fieldList;



    public MysqlTableInfoBuilder() {

      this.mysqlSideInfo = new RdbSideTableInfo();

      mysqlSideInfo.setType(MYSQL_TYPE);

      fieldList = new ArrayList<>();

    }



    public MysqlTableInfoBuilder setUrl(String url) {

      mysqlSideInfo.setUrl(url);

      return this;

    }



    public MysqlTableInfoBuilder setTableName(String tableName) {

      mysqlSideInfo.setTableName(tableName);

      mysqlSideInfo.setName(tableName);

      return this;

    }



    public MysqlTableInfoBuilder setUserName(String userName) {

      mysqlSideInfo.setUserName(userName);

      return this;

    }



    public MysqlTableInfoBuilder setPassword(String password) {

      mysqlSideInfo.setPassword(password);

      return this;

    }



    public MysqlTableInfoBuilder addField(Schema.Field field) {

      fieldList.add(field);

      return this;

    }



    public MysqlTableInfoBuilder addFields(List<Schema.Field> fields) {

      fieldList.addAll(fields);

      return this;

    }



    //		public RdbSideTableInfo setCacheType(ECacheType type){

    //			mysqlSideInfo.setCacheType(type.name());

    //			return mysqlSideInfo;

    //		}

    //

    //		public RdbSideTableInfo setCacheSize(int cacheSize){

    //			mysqlSideInfo.setCacheSize(cacheSize);

    //			return mysqlSideInfo;

    //		}

    //

    //		public RdbSideTableInfo setCacheTimeout(long cacheTimeout){

    //			mysqlSideInfo.setCacheTimeout(cacheTimeout);

    //			return mysqlSideInfo;

    //		}



    public RdbSideTableInfo finish() {

      mysqlSideInfo.setSchema(new Schema(fieldList));

      mysqlSideInfo.finish();

      return mysqlSideInfo;

    }

  }

}